<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>返回字符串char中最长的连续重复字母</title>
</head>
<body>
    <script>
        function maxCha(cha) {
            var maxLength = 0, maxCharactor = ""; 
            for (var i = 0,j = 1 ; i <= cha.length - 2 ; i = j) {
                while (cha.charAt(i) === cha.charAt(j)) {
                    if ( j - i + 1 > maxLength) {
                    maxCharactor = cha.slice(i,j + 1);
                    maxLength = j - i + 1;
                }
                j++;
                }
            }
            return maxCharactor
        }
        console.log(maxCha("mmmiijjjjkkkkkkssptr"))
    </script>
</body>
</html>